<%@ page pageEncoding="utf-8" %>
<%@include file="/commons/taglibs.jsp" %>
<!DOCTYPE html>
<html>
<fmt:bundle basename="res">
<head>
    <meta charset="utf-8">
    <title><fmt:message key='fxsshgl'/></title>
    <jsp:include page="/WEB-INF/commons/commons-header.jsp" flush="true"/>
</head>
<body>

<div class="layui-fluid">
    <div class="layui-card">
        <form name="totalForm" id="totalForm" class="layui-form layui-card-header layuiadmin-card-header-auto">
            <div class="layui-form-item">

                <div class="layui-inline">
                    <label class="layui-form-label" style="width: 80px;"><fmt:message key='fxsmc'/></label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" name="member.realName" value="${params.member.realName}">
                    </div>
                </div>

                <div class="layui-inline">
                    <label class="layui-form-label" style="width: 80px;"><fmt:message key='sjhm'/></label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" name="member.mobile" value="${params.member.mobile}">
                    </div>
                </div>

                <div class="layui-inline">
                    <label class="layui-form-label" style="width: 80px;"><fmt:message key='shzt'/></label>
                    <div class="layui-input-inline">
                        <select name="checkStatus">
                            <option value="0"><fmt:message key='qxz'/></option>
                            <option value="1" <c:if test="${params.checkStatus == 1}">selected</c:if>><fmt:message key='dsh'/></option>
                            <option value="2" <c:if test="${params.checkStatus == 2}">selected</c:if>><fmt:message key='shtg'/></option>
                            <option value="3" <c:if test="${params.checkStatus == 3}">selected</c:if>><fmt:message key='shbtg'/></option>
                        </select>
                    </div>
                </div>


                <div class="layui-inline">
                    <button class="layui-btn layui-btn-sm layuiadmin-btn-list" id="search"><i class="layui-icon layui-icon-search layuiadmin-button-btn"></i> <fmt:message key='ss'/></button>
                </div>

            </div>
        </form>
    </div>
</div>

<div class="layui-card">
    <div class="layui-field-box layui-form">

        <a href="javascript:void(0);" class="layui-btn layui-btn-sm layui-btn-warm" id="allCheck"><i class="layui-icon">&#xe605;</i><fmt:message key='plsh'/></a>

        <table class="layui-table" lay-size="sm">
            <thead>
            <tr>
                <th width="5%"><input id="checkboxs" type="checkbox" lay-ignore lay-skin="primary"/></th>
                <th><fmt:message key='xh'/></th>
                <th><fmt:message key='fxsxm'/></th>
                <th><fmt:message key='fxssjh'/></th>
                <th><fmt:message key='sqdj'/></th>
                <th><fmt:message key='yqr'/></th>
                <th><fmt:message key='sqsj'/></th>
                <th><fmt:message key='shzt'/></th>
                <th><fmt:message key='shbz'/></th>
                <th><fmt:message key='cz'/></th>
            </tr>
            </thead>
            <c:forEach items="${page.result}" var="item" varStatus="status">
                <tr>
                    <td>
                        <c:if test="${item.checkStatus == 1}">
                            <input type="checkbox" lay-ignore value="${item.id}" class="feijin-check" lay-skin="primary"/>
                        </c:if>
                    </td>
                    <td>${status.index + 1}</td>
                    <td>${item.member.realName}</td>
                    <td>${item.member.mobile}</td>
                    <td>${item.distributorLevel.name}</td>
                    <td>
                        <c:if test="${item.member.father.id == null}">-</c:if>
                        <c:if test="${item.member.father.id != null}">${item.member.father.username}</c:if>
                    </td>
                    <td><fmt:formatDate value="${item.createTime}" type="both"/></td>
                    <td>
                        <c:if test="${item.checkStatus == 1}"><fmt:message key='dsh'/></c:if>
                        <c:if test="${item.checkStatus == 2}"><fmt:message key='shtg'/></c:if>
                        <c:if test="${item.checkStatus == 3}"><fmt:message key='shbtg'/></c:if>
                    </td>
                    <td>${item.checkNote}</td>
                    <td>
                        <div class="layui-btn-container">

                            <c:if test="${item.checkStatus == 1}">
                                <a href="javascript:void(0);" data-id="${item.id}" class="layui-btn layui-btn-danger layui-btn-xs feijin-check"><fmt:message key='sh'/></a>
                            </c:if>

                        </div>
                    </td>
                </tr>
            </c:forEach>
        </table>
        <jsp:include page="/commons/page.jsp" flush="true"/>
    </div>
</div>

<script>

    layui.use("layer", function () {

        var layer = layui.layer;


        //审核
        $(".feijin-check").click(function () {
            var id = $(this).attr("data-id");
            layer.open({
                type: 2,
                content: "${web_domain}/distributor/check/"+ id +"/check",
                area: ["60%", "60%"],
                btn: ["<fmt:message key='qd'/>", "<fmt:message key='qx'/>"],
                yes: function (index, layero) {
                    layero.find('iframe').contents().find("#submit").click();
                }
            });
        });



        //全选反选
        $("#checkboxs").click(function () {
            if (this.checked) {
                $(".feijin-check:checkbox").prop("checked", true);
            } else {
                $(".feijin-check:checkbox").prop("checked", false);
            }
        });


        //批量审核
        $("#allCheck").click(function () {
            var ids = [];

            $(".feijin-check:checkbox:checked").each(function (index, item) {
                var id = $(item).val();
                ids.push(id);
            });

            if (ids.length === 0) {
                layer.msg('<fmt:message key='qxgxxyczdjl'/>');
                return false;
            }

            layer.confirm("<fmt:message key='qrshzxzdyhm?'/>", function () {
                feijin.put({
                    url: "${web_domain}/distributor/check/allCheck",
                    data: {"data": ids.join(";")}
                });
            });
        });


    });
</script>
</body>
</fmt:bundle>
</html>
